<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AlterVulsTable20180117 extends Migration
{
    /**
     * 修改漏洞表，增加漏洞URL、URl参数、payload(负载)三个字段
     *
     * @return void
     */
    public function up()
    {
        //增加漏洞修复时间字段
        Schema::table('vuls', function (Blueprint $table) {
            $table->string('form_url',"200")->default('')->comment('漏洞来源URl');
            $table->string('url_parms',"100")->default('')->comment('URl参数');
            $table->text('payload')->comment('漏洞负载');
        });
    }

    /**
     * 回滚时移除字段
     *
     * @return void
     */
    public function down()
    {
        if (Schema::hasColumn('vuls', 'payload')) {
            Schema::table('vuls', function (Blueprint $table) {
                $table->dropColumn(['form_url', 'url_parms', 'payload']);
            });
        }
    }
}
